package com.bw.car_module.carlist;

import android.widget.ImageView;
import android.widget.RadioButton;

import com.bw.car_module.R;
import com.bw.imgload_sdk.LoadImgUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import org.jetbrains.annotations.NotNull;

public class CartAdapter extends BaseQuickAdapter<CartValueEntity, BaseViewHolder> {

    public CartAdapter() {
        super(R.layout.item_car);
        addChildClickViewIds(R.id.car_item_radio,R.id.car_item_left,R.id.car_item_right,
                R.id.car_item_edt_radio);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder baseViewHolder, CartValueEntity cartValueEntity) {
        ImageView imageView = baseViewHolder.getView(R.id.car_item_img);
        LoadImgUtils.loadMatchImg(cartValueEntity.goods_icon,imageView);
        baseViewHolder.setText(R.id.car_item_title,cartValueEntity.goods_desc);
        baseViewHolder.setText(R.id.car_item_dec,cartValueEntity.goods_sku);
        baseViewHolder.setText(R.id.car_item_price,"￥"+cartValueEntity.goods_price);
        baseViewHolder.setText(R.id.car_item_num,""+cartValueEntity.goods_count);
        RadioButton radioButton = baseViewHolder.getView(R.id.car_item_radio);
        radioButton.setChecked(cartValueEntity.selFlag);
        baseViewHolder.setVisible(R.id.car_item_radio,!cartValueEntity.edtFlag);
        baseViewHolder.setVisible(R.id.car_item_edt_radio,cartValueEntity.edtFlag);
        RadioButton car_item_edt_radio = baseViewHolder.getView(R.id.car_item_edt_radio);
        car_item_edt_radio.setChecked(cartValueEntity.edtSelFlag);
    }
}
